#define _CRT_SECURE_NO_WARNINGS	1
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* reverseList(struct ListNode* head) {

    struct ListNode* cur = head;
    struct ListNode* next = NULL;
    struct ListNode* rhead = NULL;
    while (cur)
    {
        struct ListNode* next = cur->next;
        cur->next = rhead;
        rhead = cur;
        cur = next;
    }
    return rhead;


}